import svar
import numpy as np
import cv2

osdk=svar.load('svar_osdk')

decoder=osdk.CameraStreamDecoder('main')

rtmv=osdk.RTMVReader('/mnt/server0/users/liuzheng/record.rtmv')

def cbk_image(image):
  m= np.array(image)
  m.dtype='uint8'
  print(m.shape,m.dtype.name) # BGRA

  cv2.imshow('video', m)
  cv2.waitKey(10)

sub_main=osdk.messenger.subscribe('main',0,cbk_image)

while True:
  fr=rtmv.grab()
  if fr is None:
   break
  #print(fr)
  m=np.array(fr["payload"])
  #print(m.shape)
  decoder.decodeBuffer(fr["payload"])


